/*
 |-------------------------------------------------------------------------------
 | routes.js
 |-------------------------------------------------------------------------------
 | Contains all of the routes for the application
 */
import Vue from 'vue'
import VueRouter from 'vue-router'

/**
 * Extends Vue to use Vue Router
 */
Vue.use(VueRouter)

/**
 *  / - 首页
 *  /cafes -  列表
 *  /cafes/new - 新增
 *  /cafes/:id - 显示单个
 *  Makes a new VueRouter that we will use to run all of the routes for the app.
 */
export default new VueRouter({
    routes: [{
        path: '/',
        name: 'layout',
        //注意左侧键components为复数 components
        components: Vue.component('Home', require('./pages/Layout.vue')),
        children: [{
                path: 'home',
                name: 'home',
                components: Vue.component('Home', require('./pages/Home.vue'))
            },
            {
                path: 'cafes',
                name: 'cafes',
                components: Vue.component('Cafes', require('./pages/Cafes.vue')),
            },
            {
                path: 'cafes/new',
                name: 'newcafe',
                components: Vue.component('NewCafe', require('./pages/NewCafe.vue'))
            },
            {
                path: 'cafes/:id',
                name: 'cafe',
                components: Vue.component('Cafe', require('./pages/Cafe.vue'))
            }
        ]
    }]
});